﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataSource;
using Strategy.Linkage;
using System.Configuration;


namespace TimePulse
{
    class Program
    {
        static void Main(string[] args)
        {
            string sdate = ConfigurationManager.AppSettings["sdate"];
            string edate = ConfigurationManager.AppSettings["edate"];
            string curdate = edate;
            while (curdate.CompareTo(sdate) >= 0)
            {
                Run(curdate);
                //Run_para(date);
                curdate = DateUtils.GetLastTradeDate(curdate);
            }
        }

        static void Run_para(string date)
        {
            int num_leader = 3;
            int num_pair_day = 5;
            Console.WriteLine(date);
            for (int ret = 100; ret <= 300; ret += 100)
            {
                for (float scale = 0; scale < 3; scale += 1F)
                {
                    for (int span = 15; span <= 60; span += 15)
                    {
                        Console.WriteLine(String.Format("Now test the ret:{0} and scale:{1:.00} and span:{2}s", ret, scale, span));
                        StrategyPara.set_para(ret, scale, span, num_leader, num_pair_day);
                        TimePulse tp = new TimePulse(date);
                        tp.Run();
                    }
                }
            }

        }

        static void Run(string date)
        {
            int num_leader = int.Parse(ConfigurationManager.AppSettings["num_leader"]);
            int back_window = int.Parse(ConfigurationManager.AppSettings["back_window"]);
            int ret_leader = int.Parse(ConfigurationManager.AppSettings["ret_leader"]);
            float scale_amt = float.Parse(ConfigurationManager.AppSettings["scale_amt"]);
            int span_follower = int.Parse(ConfigurationManager.AppSettings["span_follower"]);

            StrategyPara.set_para(ret_leader, scale_amt, span_follower, num_leader, back_window);
            TimePulse tp = new TimePulse(date);
            tp.Run();
        }
    }
}
